package com.huiyeji.dynamic.core.builder;

import com.huiyeji.dynamic.core.exception.IllegalDynamicObjectException;
import com.huiyeji.dynamic.core.provider.DynamicForceMethodProvider;
import com.huiyeji.dynamic.core.provider.DynamicMethodProvider;
import com.huiyeji.dynamic.core.DynamicObjectInfo;
import com.huiyeji.dynamic.core.annotations.*;

@Deprecated
@DynamicBean("Force")
public class DynamicForceObjectBuilder extends AbstractDynamicBuilder{
    @Override
    public DynamicObjectInfo initialize(Object object) {
        if (object == null){
//            return null;
            throw new IllegalDynamicObjectException("Force Dynamic Error : origin object is null !");
        }
        Class<?> aClass = object.getClass();
        String name = aClass.getSimpleName();
        if (aClass.isAnnotationPresent(DynamicBean.class)){
            name = aClass.getAnnotation(DynamicBean.class).value();
        }
        return new DynamicObjectInfo(name,object);
    }

    @Override
    public DynamicMethodProvider buildDynamicMethodProvider(DynamicObjectInfo info) {
        return super.buildDynamicMethodProvider(info);
    }
}
